package vaccine.appointment.system.appointmentrecord.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 预约疫苗策略工程
 */
@Component
public class AppointmentFactory {

    @Autowired
    private List<AppointmentStrategy> appointmentStrategyList;

    /**
     * 根据疫苗类型选择相应的预约策略
     * @param code
     * @return
     */
    public AppointmentStrategy getStrategy(int code) {
        for(AppointmentStrategy appointmentStrategy : appointmentStrategyList) {
            if(appointmentStrategy.getCode() == code) {
                return appointmentStrategy;
            }
        }
        return null;
    }

}
